﻿using System;//
using System.DHTML;
using Sys;
using Sys.UI;
using Sys.Mvc;

using JQuerySharp;
using VietPublisher.Scripts.Resources;



static public class Account_Script
{
    public static string ControllerUrl = "Account";
    public static void SaveUser(Dictionary form)
    {
        ItemInfor[] items = new ItemInfor[] {
           // new ItemInfor("RepTelNo", true, 12,RepTelNo, ValueType.Text, null),
            new ItemInfor("UserName",true,100,null, ValueType.Text, null),
            //new ItemInfor("Publisher",true,100,UIHelper.NumberReg, ValueType.Text, null),
            //new ItemInfor("AuthorName",true,100,null, ValueType.Text, null),
            //new ItemInfor("BookIntro",true,100,null, ValueType.Text, null),
          
            
        };
        if (UIHelper.ValidateItems(items, true))
        {
            //Dictionary form = (Dictionary)(object)Document.GetElementById("Form_SiteManager");
            UIHelper.SubmitAjax(form, "POST", null,
            new MvcCallback(delegate(AjaxContext context)
            {
                string result = context.request.Executor.ResponseData.ToString();
                Script.Alert(result);
                if (result == "true")
                {
                    Script.Alert(Common.OperationSuccess);
                }
                else
                {
                    Script.Alert(" insert false");
                }


                Utils.Navigate(SC_Common.BasePath + ControllerUrl + "/Create");
            }),
            new MvcCallback(delegate(AjaxContext context)
            {
                Script.Alert(Common.OperationFailed);
            }));
        }
        else {
            Script.Alert("not validate");
        }


       
    }
    public static void SubmitLogin(Dictionary form)
    {
        //Dictionary form = (Dictionary)(object)Document.GetElementById("Form_SiteManager");
        UIHelper.SubmitAjax(form, "POST", null,
        new MvcCallback(delegate(AjaxContext context)
        {
            string result = context.request.Executor.ResponseData.ToString();
            if (result == "False")
            {
                //Script.Alert(Common.OperationSuccess);
                Script.Alert("Login False!!!!");
               
            }
            else
            {
                Script.Alert("login success");
                Utils.Navigate(result);
                
            }
        }),
        new MvcCallback(delegate(AjaxContext context)
        {
            Script.Alert(Common.OperationFailed);
        }));
    }

}